FlyTalk.views.HelpView = Ext.extend(Ext.Panel, {
	layout: 'card', 
	scroll: true,
	title: 'help',
    initComponent: function (options) {

    	// back button on toolbar
		this.backButton = new Ext.Button({
			id: "homeButton",
			iconCls: 'home',
			iconMask: true,
			handler: this.backButtonTap,
			scope: this
		});

		
			// Tweet toolbar
		this.tweetToolbar = new Ext.Toolbar({
			id: 'tweetToolbar',
			title: 'Help Out',
			doc: 'top',
			layout: 'hbox',
			items: [
			    this.backButton,
				{xtype: 'spacer'},
			]
		});

        this.dockedItems = [this.tweetToolbar];
  		
        
		
		this.tweetList = new Ext.NestedList({
			fullscreen: true,
			scroll: true,
			title: "Help Out",
			emptyText: '<div style="margin:5px;">blah.</div>',
			displayfield: 'text',
			toolbar: this.tweetToolbar, // can be removed to have automatic toolbar show up.

			store: FlyTalk.stores.helpStore,
			
			getItemTextTpl: function(node) {
				var tempTpl = 
					'<tpl if="type === \'\'">' +
						'<div> {text} </div>'+
					'</tpl>'+
					'<tpl if="type === \'Reviews\'">' +
						'<div> {text} </div>'+
					'</tpl>'+
					'<tpl if="type === \'Questions\'">' +
						'<div> {userName}: {text} </div>'+
					'</tpl>'+
					'<tpl if="type === \'Time Estimates\'">' +
						'<div>{text} </div>'+
					'</tpl>';
					
				return tempTpl;
			},
	
			listeners:{
				disclose: function(dv, tweet, index, evt){
					//FlyTalk.views.HelpView.onMenu(index);
				},
				
				beforecardswitch: function(dv, newCard, oldCard, index, anim){
					//Ext.Msg.alert('Success' + index);
					if (index ==0){
						Ext.get('homeButton').setVisible(true);
					}
					else{
						Ext.get('homeButton').setVisible(false);
					}
					
				}
			},
		});
	
		this.items = [this.tweetList];
		
		FlyTalk.views.HelpView.superclass.initComponent.call(this);
    },
    
    onMenu: function (ind) {
        Ext.dispatch({
            controller: FlyTalk.controllers.ftController,
            action: 'openMenu',
           // post: record,
            index: ind,
        });
    },
    
    backButtonTap: function () {
        Ext.dispatch({
            controller: FlyTalk.controllers.ftController,
            action: 'openHome'
        });
    },
    
});